/*
 * analizar.cpp
 *
 *  Created on: 05/07/2011
 *      Author: jem
 */
#include "analizarACK/compara-ACKs.h"
#include "analizarDATA/compara-DATApkts.h"
#include "analizarRTT/calcular-RTT.h"

int main(int argn, char *argc[]) {

	// Variables
//	int ack1, ack2;
//	int data1, data2;
	int perdidos, perd, perd1, perd2;
	int total, subtotal, subtotal1, subtotal2;
//	int a, b, i;

	//Compara ACK
	compara(perd, subtotal);
	perdidos = perd;
	total = subtotal;

	comparaDup(perd, subtotal);
	perdidos = perdidos + perd;
	total = total + subtotal;

	float porcentotal;
	if (total != 0) {
		porcentotal = (perdidos * 1.0 / total) * 100.0;
	} else {
		porcentotal = 0.0;
	}

	resACKsOUT << "\tTotal: " << perdidos << " ACKs perdidos: " << porcentotal
			<< "% " << "de " << total << endl;

	system("gnuplot -persist < analizarACK/dibujargrafica-ACKs.plt >> analizar.log");

	resACKsOUT.close();

	// Compara DATApkts
	compara(perd1, subtotal1, perd2, subtotal2);

	perdidos = perd1 + perd2;
	total = subtotal1 + subtotal2;

	if (total != 0) {
		porcentotal = (perdidos * 1.0 / total) * 100.0;
	} else {
		porcentotal = 0.0;
	}

	resDATApOUT << "\tTotal: " << perdidos << " DATApkts perdidos: "
			<< porcentotal << "% " << "de " << total << endl;

	system("gnuplot -persist < analizarDATA/dibujargrafica-DATApkts.plt >> analizar.log");

	resDATApOUT.close();

	// Calcula RTT
	calculaRTT();

	system("gnuplot -persist < analizarRTT/dibujargrafica-RTTs.plt >> analizar.log");
	system("gnuplot -persist < analizarRTT/dibujargrafica-RTTs1+estimados.plt >> analizar.log");
	system("gnuplot -persist < analizarRTT/dibujargrafica-RTTs2+estimados.plt >> analizar.log");

	resRTTsOUT.close();

}
